import urllib
import urllib2
import re
from mechanize import Browser
import mechanize
from urllib2 import urlopen
from ClientForm import ParseResponse
def f1():
    br = Browser()
    url="https://www.elections2011.eg/proxy.php?type=nid&id=0"
    id="22805041700035"
    f = br.open("http://www.gmodules.com/ig/ifr?url=http://alimaher-egyptian-elections.googlecode.com/hg/voter-info/voter-info-gadget-egypt.xml&nid="+id)
    #f=br.open("http://www.google.com/")
    print(f.read())
    forms = br.forms()
    #print("here "+forms)
    for form in br.forms():
        print("here")
        print form
        """
    br.select_form(name="nid_lookup")
    br["nid"] = ["22805041700035"] 
    response = br.submit()  # submit current form
    print(response)"""
def f2():


    response = urlopen("http://www.elections2011.eg/#gadget")
    forms = ParseResponse(response, backwards_compat=False)
    #form = forms[0]
    print len(forms)
    #form["comments"] = "Thanks, Gisle"
f1()
